package com.demo.study.reflection;

import lombok.Data;

import java.io.Serializable;

/**
 * @author Baymax
 * @since 2021/10/10
 */
public class Demo01 {
    public static void main(String[] args) throws ClassNotFoundException {
        // 通过全类名获取
        Class<?> per_01 = Class.forName("com.demo.study.reflection.Person");

        Person person = new Person();

        // 通过实体get
        Class<? extends Person> per_02 = person.getClass();

        // 通过类名获取
        Class<Person> per_03 = Person.class;

        System.out.println(per_01); // class com.demo.study.reflection.Person
        System.out.println(per_01 == per_02);
        System.out.println(per_01 == per_03);
        System.out.println(per_02 == per_03);
    }
}

@Data
class Person implements Serializable {
    private static final long serialVersionUID = 107525321402546L;

    private String name;

    private String age;
}
